<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>资源操作</title>
    <meta name="author" content="yeshop Team" />
    <meta name="copyright" content="yeshop" />
    <% include("/WEB-INF/views/common/include.html"){}%>
    <link href="${base}/res/css/common.css" rel="stylesheet" type="text/css" />
    <script src="${base}/res/plugins/hplus/js/plugins/layer/layer.min.js"></script>
    <script type="text/javascript">
        function check(){
            var resourceName=$("#resourceName").val();
            var resourceOrderList=$("#resourceOrderList").val();
            var listReg=/^\d*\d*\d+$/;
            if(!resourceName){
                layer.msg("请输入分类名称!");
                return false;
            }
            if(!listReg.test(resourceOrderList) || parseInt(resourceOrderList)>999){
                layer.msg("排序请输入0-999的正整数!");
                return false;
            }
        }
    </script>
    <%
    var isAdd = false;
    var isEdit = false;

    if(isEmpty(resource.id)){
    isAdd = true;
    }else{
    isEdit = true;
    }%>
</head>
<body>
<div class="path">
    用户管理 &raquo; <%if(isAdd){%>添加资源<%}else{%>编辑资源<%}%>
</div>
<form id="" action="<%if (isAdd){%>${base}/shop/resource/save<%}else{%>${base}/shop/resource/update<%}%>" method="post" onsubmit="return check()">
    <table class="input">
        <tr>
            <th>
                <span class="requiredField">*</span>分类名称:
            </th>
            <td colspan="4">
                <input type="text" id="resourceName" name="resource.name" class="text" value="${resource.name!}"/>
                <input type="hidden" name="resource.id" value="${resource.id!}" />
                <input type="hidden" name="resource.path" value="${resource.path!}" />
            </td>
        </tr>
        <tr>
            <th>
                上级分类:
            </th>
            <td colspan="4">
                <%if(isAdd){%>
                <select name="resource.parent_id" data-am-selected="{btnSize: 'sm', btnStyle: 'secondary',maxHeight: 120}">
                    <option value="">顶级分类</option>
                    <%for(list in resourceTreeList){%>
                    <option value="${list.id}">
                        <%if (list.level != 0){%>
                        <%for( i in range(0,list.level!0)){%>------<%}%>
                        <%}%>
                        ${list.name}
                    </option>
                    <%}%>
                </select>
                <%}else{%>
                ${resource.parent.name!'顶级分类'}
                <%}%>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>排序:
            </th>
            <td colspan="4">
                <input type="text" id="resourceOrderList" name="resource.orderList" class="text" value="${resource.orderList!50}" title="只允许输入零或正整数" required/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>url:
            </th>
            <td colspan="4">
                <input type="text" name="resource.url" class="text" value="${resource.url!}" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>icon:
            </th>
            <td colspan="4">
                <input type="text" name="resource.icon" class="text" value="${resource.icon!}" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>备注:
            </th>
            <td colspan="4">
                <textarea name="resource.description" class="text" rows="7">${resource.description!}</textarea>
            </td>
        </tr>
        <tr>
            <th>
                &nbsp;
            </th>
            <td colspan="4">
                <input type="submit" class="button" value="保存"/>
                <input type="button" class="button" onclick="window.history.back(); return false;" value="返回"/>
            </td>
        </tr>
    </table>
</form>
</body>
</html>